import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import*

testCase="DBshop006_删除取消订单流程"
# 登录后台界面
firefox=openBrowser(urlAdmin)
firefox.get(urlAdmin)
DBshopLoginAdmin(firefox)
# 1.点击销售管理订单管理界面。
DBshopEnterMenu2(firefox, '销售管理', '订单管理')

# 2.在订单状态点击已取消一栏，点击“搜索”按钮一款，勾选之后，选择删除，点击提交操作。
firefox.find_element_by_xpath('//option[text()="已取消"]').click()
firefox.find_element_by_xpath("//button").click()
s=firefox.find_element_by_xpath('//body').text
print(s)
l="订单数\："
r="\)"
num1=reGetString(s,l,r)
time.sleep(3)

firefox.find_element_by_link_text('编辑查看').click()
time.sleep(5)
firefox.find_element_by_partial_link_text("删除订单").click()
time.sleep(3)
firefox.switch_to.alert.accept()
time.sleep(2)
# 3.删除成功
firefox.find_element_by_xpath('//option[text()="已取消"]').click()
firefox.find_element_by_xpath("//button").click()
s=firefox.find_element_by_xpath('//body').text
time.sleep(5)
num2=reGetString(s,l,r)
if int(num1) == int(num2)+1:
    writeLog("%s 测试通过" % testCase)
else:
    writeLog("%s 测试失败" % testCase)
    getPhoto(firefox)
firefox.quit()


